/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ShapeService.bouncebox;

import ShapeService.bounceboxframework.Shape;
import java.awt.Graphics2D;

public class Rectangle extends Shape {

    private double contactRadius;
    private int width;
    private int height;

    public Rectangle(int x, int y, int width, int height) {
        super(x,y);
        this.width = width;
        this.height = height;
        contactRadius = Math.sqrt(width*width + height*height) * 0.8 / 2;
    }

    public int getWidth(){return width;}
    public int getHeight(){return height;}

    public double getContactRadius() {return contactRadius;}
    public double getMass() {return width*height;}
    public void draw(Graphics2D g) {
        g.setColor(getColor());

        int left = (int) (getX()-width/2);
        int top = (int) (getY()-height/2);
        g.fillRect(left,top, width, height);
    }
}
